age on R2sThis code implements GAMM models for continuous variables including continuous x continuous interactions. Significance is tested using parametric bootstrapping.
# This function:
# 1. executes the GAMM model,
# 2. sends output to the parametric bootstrap (if requested),
# 3. prints a regression table, and
# 4. sends the model to the visualizer for plotting.
gamm_model <- function(df, model_formula, this_label, smooth_var, int_var = NULL,weight_var = NULL,group_var, pbootstrap = F, longPlot = F, model_test = T){
cat(sprintf("\n\n### Results for %s\n",this_label))
if (is.null(weight_var)) {
df$weight <- 1 #if no weighting variable is provided, weight all obs equally.
} else {
df$weight <- unlist(df[,weight_var]) # Use weight variable if provided.
}
model_formula <- as.formula(model_formula)
if(!"exclusions" %in% colnames(df)) {
df$exclusions <- FALSE; #there is no exclusions column so make one that excludes none
}
g1<-gamm(model_formula,
data=df,
random = list(bblid =~ 1),
subset = exclusions == F,
weights = weight)
if (model_test == T){
if (pbootstrap == T) {
#Send to bootstrap function
g1$pb<-pboot(g1)
#Print a table that shows the bootstrap outcome
print(g1$pb %>%
summary() %>%
.$test %>%
as.data.frame() %>%
kable(caption = sprintf("Parametric Bootstrap test for %s",this_label)) %>%
kable_styling(full_width = F, position = "left",bootstrap_options = c("striped"))
)
if (isTRUE(all.equal(g1$pb$bestmod,model_formula))) {
cat("The initial (more complicated) model is best")
g <- g1
#This next part is no longer implemented (refit the model using unfixed degrees of freedom). Effective part is commented out below.
if (str_detect(deparse(model_formula),"F1_Social_Cognition_Efficiency") &this_label == "Right_Pallidum_male") {
plot_formula <- model_formula
} else {
plot_formula <- as.formula(gsub(", fx = T","",deparse(model_formula)))
}
cat(deparse(plot_formula))
plotg<-g
# plotg <- gamm(plot_formula,
# data = df,
# random = list(bblid =~1),
# subset = exclusions == F)
} else {
cat("The simpler model is best")
g <-gamm(as.formula(g1$pb$bestmod),
data=df,
random = list(bblid =~ 1),
subset = exclusions == F,
weights = weight)
#Again, this part not implemented (model not refit with unfixed df)
plot_formula <- as.formula(gsub("ti\\(",'te\\(',deparse(g$gam$formula)) %>% gsub(", fx = T", "", .))
plotg<-g
# plotg <-gamm(plot_formula,
# data=df,
# random = list(bblid =~ 1),
# subset = exclusions == F)
}
} else {
if (!is.null(int_var)) {
# We are not bootstrapping, but there is an interaction variable
s<-summary(g1$gam)
if (s$s.table[grep(x=rownames(s$s.table),pattern = int_var),"p-value"] <.05) {
#Checked if interaction is sig, if so keep in the model
g <- g1
plot_formula <- as.formula(gsub(", fx = T", "", deparse(model_formula)))
plotg <- g
} else {
#Interaction is not sig, remove from the model
cat("The simpler model is best")
thisResp <- as.character(g1$gam$terms[[2]])
theseVars <- attr(terms(model_formula),"term.labels")
new_formula <- reformulate(theseVars[0:(length(theseVars)-1)],response = thisResp)
g <-gamm(as.formula(new_formula),
data=df,
random = list(bblid =~ 1),
subset = exclusions == F,
weights = weight)
plot_formula <- as.formula(gsub("ti\\(",'te\\(',deparse(g$gam$formula)) %>% gsub(", fx = T", "", .))
plotg<-g
}
} else {
#There is no interaction term, just plot.
g <- g1
plot_formula <- as.formula(gsub(", fx = T", "", deparse(model_formula)))
plotg <- g
}
}
} else {
g <- g1
plotg<-g
}
g$gam$data<-df %>%
filter(exclusions == F)
#Display model results:
s_tidytable<- tidy(g$gam)
p_tidytable <- tidy(g$gam,parametric = T)
snames = names(s_tidytable)
pnames = names(p_tidytable)
names(s_tidytable)=pnames
thisBIC <- BIC(g$lme)
numObs <- g$lme$dims$N
g$BIC <- thisBIC
stattable <- rbind(p_tidytable,snames,s_tidytable) %>%
kable(caption = sprintf("Regression table from gamm in %s, BIC = %1.2f, obs = %d",this_label,thisBIC,numObs)) %>%
kable_styling(full_width = F, position = "left")
print(stattable)
#Send final model to visualizer:
if (s_tidytable$p.value[nrow(s_tidytable)]<.05) {
if (longPlot == T) {
g$pl <- longitudinal_plot(g,plabels = this_label)
} else {
g$pl <- visualize_models(plotg,plabels = this_label, smooth_var = smooth_var, int_var = int_var, group_var = group_var)
}
}
#Return result object
result <- g
return(result)
}
This procedure is lifted from https://github.com/PennBBL/groupAnalysis/wiki/Model-Comparison-Using-Parametric-Bootstrap
## Parametric bootstrap of likelihood ratio test for nested models
pboot <- function(modelobj){
numsims <- 500
df <- modelobj$gam$model
thisResp <- as.character(modelobj$gam$terms[[2]])
f1 <- modelobj$gam$formula
theseVars <- attr(terms(f1),"term.labels")
f2 <- reformulate(theseVars[0:(length(theseVars)-1)],response = thisResp)
g1 <- gam(f1,data = df,weights = `(weights)`)
g2 <- gam(f2,data = df,weights = `(weights)`)
mat1 <- model.matrix(g1)
mat2 <- model.matrix(g2)
bblid<-df$bblid
y <- df[,thisResp]
w <- unlist(df[,"(weights)"])
m1 <- lmer(y ~ -1 + mat1 + (1|bblid),weights = w)
m2 <- lmer(y ~ -1 + mat2 + (1|bblid),weights = w)
refdist <- PBrefdist(m1, m2, nsim=numsims)#, cl=cl)
pb <- PBmodcomp(m1, m2, ref = refdist)
int_pval <- pb$test["PBtest","p.value"]
if (int_pval < .05) {
pb$bestmod <- f1
} else {
pb$bestmod <- f2
}
return(pb)
}
Fit nonlinear age effect and check for age*sex interaction (factor smooth interaction: s(age, by = oSex)) oSex is Sex specified as an ordered factor to appropriately test for the interaction (female against male reference)
model_formula <- "R2s ~ sequence + oSex + s(age,k=4, fx=T) + s(age, k=4, fx = T, by = oSex)"
models <- longTable %>%
group_by(ROI)%>%
nest()%>%
mutate(results=purrr::pmap(list(data,model_formula,this_label = ROI, pbootstrap = F, longPlot = T),.f=gamm_model))
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.7725811888475 | 0.4418781558239 | 40.2205471227917 | 1.24633665554264e-237 |
| sequenceB0map_onesizefitsall_v3 | -0.623085998926579 | 0.448128328795958 | -1.39041867895453 | 0.164616927635209 |
| sequenceB0map_v4 | 2.24781461214699 | 0.478488410465983 | 4.69774097549807 | 2.88203097220329e-06 |
| oSex.L | 0.315735918185645 | 0.103193506624625 | 3.059649085617 | 0.00225694521495669 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000002 | 3 | 20.4940934007221 | 5.26207497366208e-13 |
| s(age):oSexfemale | 3 | 3 | 0.400623669731159 | 0.75257585078062 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.6677215197485 | 0.208621890562926 | 79.8944035775628 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.262161246096283 | 0.211676722521269 | 1.2384982296291 | 0.215733514212521 |
| sequenceB0map_v4 | 0.237049079936652 | 0.227172304348336 | 1.04347702338385 | 0.296902802137554 |
| oSex.L | -0.0469991009696479 | 0.0475184636267328 | -0.989070297786465 | 0.322795139823381 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000003 | 3 | 46.5588980846991 | 1.0265049486821e-28 |
| s(age):oSexfemale | 2.99999999999998 | 2.99999999999998 | 2.4212879445373 | 0.0643878623448547 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.4077431686255 | 0.246834955589472 | 62.4212366187356 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.354827877293991 | 0.250019680916723 | -1.41919978456487 | 0.156057495903268 |
| sequenceB0map_v4 | -0.0428467016925919 | 0.26477367095904 | -0.161823875982065 | 0.871467283988404 |
| oSex.L | 0.115226724976578 | 0.060188115504299 | 1.91444314232346 | 0.0557618225737431 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000001 | 3 | 6.65514367712182 | 0.000183646346673905 |
| s(age):oSexfemale | 3.00000000000003 | 3 | 0.101595291525597 | 0.959111961569524 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 21.726192506943 | 0.290143648014129 | 74.8808138852828 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.644766152256348 | 0.29433364160001 | 2.19059618449108 | 0.0286410932291355 |
| sequenceB0map_v4 | 0.142064726438526 | 0.315168217161323 | 0.450758416308865 | 0.652231631428754 |
| oSex.L | -0.0681025988146648 | 0.0668350226996268 | -1.01896574675728 | 0.308390627537341 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 100.984769127909 | 1.86338065267351e-61 |
| s(age):oSexfemale | 2.99999999999999 | 2.99999999999999 | 4.5818446773292 | 0.00336466095608642 |
## Scale for 'y' is already present. Adding another scale for 'y', which
## will replace the existing scale.
## Warning: Removed 2 rows containing missing values (geom_path).
## Warning: Removed 2 rows containing missing values (geom_point).
ti: ti(age) + ti(Psychosis) + ti(age,Psychosis)From documentation: This model specifies a main effects + interaction structure such as: y ~ ti(x) + ti(z) + ti(x,z)
ti is the proper way of specifying an interaction term in the context of included main effect terms:
“This functional ANOVA decomposition is supported by ti terms, which produce tensor product interactions from which the main effects have been excluded, under the assumption that they will be included separately. For example the ~ ti(x) + ti(z) + ti(x,z) would produce the above main effects + interaction structure. This is much better than attempting the same thing with s or te terms representing the interactions (although mgcv does not forbid it). Technically ti terms are very simple: they simply construct tensor product bases from marginal smooths to which identifiability constraints (usually sum-to-zero) have already been applied: correct nesting is then automatic (as with all interactions in a GLM framework). See Wood (2017, section 5.6.3).”
Run the models:
cog_vars <- c("NAR_Overall_Accuracy","NAR_Overall_Efficiency","NAR_F2_Social_Cog_Accuracy","NAR_F1_Social_Cognition_Efficiency","mpraxis_mp2rtcr","wrat4_std")
## First the age models
# model_formula <- sprintf("%s ~ sequence + timepoint + oSex + s(age,k=4, fx=T) + s(age, k=4, fx = T, by = oSex)",cv)
# models <- dataTable %>%
# filter(scan2cnbmonths<6) %>%
# gamm_model(.,model_formula,
# this_label = cv,
# smooth_var = "age",
# group_var = "bblid",
# int_var = 'oSex',
# pbootstrap = T,
# longPlot = F)
for (r in rois) {
cat(sprintf("\n## Results for %s\n",r))
for (cv in cog_vars) {
cat(sprintf("\n### %s\n",cv))
thisTable <- dataTable
if (cv == "mpraxis_mp2rtcr") {
thisTable$exclusions <- thisTable$scan2cnbmonths>6 | thisTable$mpraxis_mp2rtcr>1500
}
else {
thisTable$exclusions <- thisTable$scan2cnbmonths>6
}
# First check main effects
add_formula <- sprintf("%s ~ sequence + timepoint + sex + s(age, k=4, fx = T) + s(%s, k=4, fx = T)",r,cv)
gamm_model(thisTable,
add_formula,
this_label = sprintf("%s %s M.E.",r,cv),
smooth_var = cv,
group_var = "bblid",
pbootstrap = F,
model_test = F)
# Compare the two interaction models
cat('\n### Comparing interatcion models...\n')
# Bivariate interaction
bv_formula <- sprintf(
"%s ~ sequence + timepoint + sex + ti(age, k=4, fx = T) + ti(%s, k=4, fx = T) + ti(age,%s, k=4, fx = T)",
r,cv,cv)
# Linear varying coefficient interaction
vc_formula <- sprintf(
"%s ~ sequence + timepoint + sex + s(age, k=4, fx = T) + s(age, by = %s, k=4, fx = T)",
r,cv)
bv <- gamm(as.formula(bv_formula),
random = list(bblid=~1),
data = thisTable,
subset = thisTable$exclusions == 0)
vc <- gamm(as.formula(vc_formula),
random = list(bblid=~1),
data = thisTable,
subset = thisTable$exclusions == 0)
bic<-BIC(bv$lme,vc$lme)
bestmod <- gsub(row.names(bic)[which.min(bic$BIC)],pattern = "$lme",replacement = "", fixed = T)
switch (bestmod,
"bv" = {model <- bv},
"vc" = {model <- vc}
)
model_formula <- model$gam$formula
cat(sprintf("\n\nbest model is %s\n",deparse(model_formula)))
a <- anova(model$gam)
print(kable(a$pTerms.table)%>%kable_styling(position = "left"))
print(kable(a$s.table)%>%kable_styling(position = "left"))
# Now check if interaction is significant
gamm_model(thisTable,
model_formula,
this_label = sprintf("%s %s final model",r,cv),
smooth_var = "age",
int_var = cv,
group_var = "bblid",
pbootstrap = F)
}
}
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3529856190119 | 0.273281628437207 | 56.1800868459754 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.490199058971442 | 0.261730440869848 | -1.87291572712097 | 0.061303780698564 |
| sequenceB0map_v4 | -0.0429404726639919 | 0.306550506633679 | -0.140076338922202 | 0.888621323988869 |
| timepoint.L | -0.176818367568984 | 0.148542578887258 | -1.19035477163209 | 0.234123803751784 |
| timepoint.Q | -0.14318414500882 | 0.0788423620581044 | -1.81608137137365 | 0.0695876150199931 |
| sexfemale | 0.221803168549537 | 0.0903724894968453 | 2.45432177186266 | 0.0142451176928934 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 5.25813154974345 | 0.00131397652817482 |
| s(NAR_Overall_Accuracy) | 2.99999999999999 | 2.99999999999999 | 0.738539519423275 | 0.529081070282189 |
best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_Overall_Accuracy, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 4.764357 | 0.0086776 |
| timepoint | 2 | 1.622617 | 0.1977803 |
| sex | 1 | 6.297585 | 0.0122109 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 4.035093 | 0.0071967 |
| s(age):NAR_Overall_Accuracy | 4 | 4 | 1.090170 | 0.3598747 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3538681544429 | 0.273259612632523 | 56.1878427863052 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.490418475926611 | 0.261300845588404 | -1.87683463029855 | 0.0607633901279866 |
| sequenceB0map_v4 | -0.0402495851848337 | 0.306277785177037 | -0.131415294000407 | 0.895467015996446 |
| timepoint.L | -0.179153292242278 | 0.148433705445786 | -1.20695829632652 | 0.227666598247195 |
| timepoint.Q | -0.1477110647832 | 0.0788512266278031 | -1.873288103436 | 0.0612516423736164 |
| sexfemale | 0.217916894308364 | 0.0899684063581489 | 2.42214909799418 | 0.0155643094616477 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 8.79376273840496 | 8.93488116469911e-06 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3770937181106 | 0.27328530121216 | 56.2675476869972 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.529389140638872 | 0.261790641664416 | -2.0221851219475 | 0.043361225556122 |
| sequenceB0map_v4 | -0.0713755038812788 | 0.306682355797909 | -0.232734301572642 | 0.816004282703344 |
| timepoint.L | -0.214064828554569 | 0.149445198596866 | -1.43239682883367 | 0.152270135056689 |
| timepoint.Q | -0.151606954796267 | 0.0790279204632367 | -1.91839737029134 | 0.0552789604100243 |
| sexfemale | 0.217342490323903 | 0.0899435431092794 | 2.41643238425505 | 0.0158101528067682 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 3.71630821654775 | 0.0111675572024455 |
| s(NAR_Overall_Efficiency) | 3 | 3 | 1.35563782621293 | 0.254825074839028 |
best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_Overall_Efficiency, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 5.135467 | 0.0060041 |
| timepoint | 2 | 1.852837 | 0.1572048 |
| sex | 1 | 5.970541 | 0.0146789 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 3.640933 | 0.0123796 |
| s(age):NAR_Overall_Efficiency | 4 | 4 | 0.988170 | 0.4128499 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3538681544429 | 0.273259612632523 | 56.1878427863052 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.490418475926611 | 0.261300845588404 | -1.87683463029855 | 0.0607633901279866 |
| sequenceB0map_v4 | -0.0402495851848337 | 0.306277785177037 | -0.131415294000407 | 0.895467015996446 |
| timepoint.L | -0.179153292242278 | 0.148433705445786 | -1.20695829632652 | 0.227666598247195 |
| timepoint.Q | -0.1477110647832 | 0.0788512266278031 | -1.873288103436 | 0.0612516423736164 |
| sexfemale | 0.217916894308364 | 0.0899684063581489 | 2.42214909799418 | 0.0155643094616477 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 8.79376273840496 | 8.93488116469911e-06 |
best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_F2_Social_Cog_Accuracy, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 4.698218 | 0.0092665 |
| timepoint | 2 | 1.561555 | 0.2102023 |
| sex | 1 | 5.851337 | 0.0157016 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 4.986321 | 0.0019210 |
| s(age):NAR_F2_Social_Cog_Accuracy | 4 | 4 | 1.498620 | 0.2002363 |
best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_F1_Social_Cognition_Efficiency, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 5.337299 | 0.0049146 |
| timepoint | 2 | 1.856833 | 0.1565797 |
| sex | 1 | 5.311020 | 0.0213477 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 4.185903 | 0.0058429 |
| s(age):NAR_F1_Social_Cognition_Efficiency | 4 | 4 | 1.422772 | 0.2240915 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3474896469627 | 0.272938738251096 | 56.2305290385107 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.493369424785766 | 0.261034914617774 | -1.89005147264761 | 0.0589726799128901 |
| sequenceB0map_v4 | -0.0279431588185841 | 0.306065316149876 | -0.0912980247814186 | 0.927269809657064 |
| timepoint.L | -0.190297424910458 | 0.148183443610887 | -1.28420166432465 | 0.199299513080264 |
| timepoint.Q | -0.154231733945406 | 0.0787542250150184 | -1.95839313911087 | 0.0503968242226789 |
| sexfemale | 0.223319171363192 | 0.0901821494337532 | 2.47631236076536 | 0.0134008685469919 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000001 | 3 | 7.29798120041324 | 7.45758322910193e-05 |
| s(mpraxis_mp2rtcr) | 3 | 3 | 0.984725642647946 | 0.39908770557808 |
best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = mpraxis_mp2rtcr, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 4.961769 | 0.0071334 |
| timepoint | 2 | 1.771671 | 0.1704579 |
| sex | 1 | 6.457642 | 0.0111628 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 0.2626362 | 0.8523416 |
| s(age):mpraxis_mp2rtcr | 4 | 4 | 0.9992829 | 0.4068053 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3538681544429 | 0.273259612632523 | 56.1878427863052 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.490418475926611 | 0.261300845588404 | -1.87683463029855 | 0.0607633901279866 |
| sequenceB0map_v4 | -0.0402495851848337 | 0.306277785177037 | -0.131415294000407 | 0.895467015996446 |
| timepoint.L | -0.179153292242278 | 0.148433705445786 | -1.20695829632652 | 0.227666598247195 |
| timepoint.Q | -0.1477110647832 | 0.0788512266278031 | -1.873288103436 | 0.0612516423736164 |
| sexfemale | 0.217916894308364 | 0.0899684063581489 | 2.42214909799418 | 0.0155643094616477 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 8.79376273840496 | 8.93488116469911e-06 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3549043748491 | 0.27715789377554 | 55.4012882897879 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.493418129011292 | 0.265209926803257 | -1.86048137397711 | 0.0630439874322876 |
| sequenceB0map_v4 | -0.0454157105988698 | 0.309675199629443 | -0.146655950018646 | 0.88342641581938 |
| timepoint.L | -0.176057510334206 | 0.149407555619161 | -1.17837086353902 | 0.238865267456396 |
| timepoint.Q | -0.153785014970552 | 0.0792948879260972 | -1.93940642319691 | 0.0526688204839706 |
| sexfemale | 0.22584779824564 | 0.0903740901393986 | 2.49903260876296 | 0.0125763474175155 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 9.028327805155 | 6.41155061519337e-06 |
| s(wrat4_std) | 3 | 3 | 0.705462687536168 | 0.548788080699956 |
best model is Caudate ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = wrat4_std, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 4.621176 | 0.0100042 |
| timepoint | 2 | 1.799607 | 0.1657774 |
| sex | 1 | 6.546723 | 0.0106207 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 2.003046 | 0.1117195 |
| s(age):wrat4_std | 4 | 4 | 1.232055 | 0.2953177 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 15.3538681544429 | 0.273259612632523 | 56.1878427863052 | 0 |
| sequenceB0map_onesizefitsall_v3 | -0.490418475926611 | 0.261300845588404 | -1.87683463029855 | 0.0607633901279866 |
| sequenceB0map_v4 | -0.0402495851848337 | 0.306277785177037 | -0.131415294000407 | 0.895467015996446 |
| timepoint.L | -0.179153292242278 | 0.148433705445786 | -1.20695829632652 | 0.227666598247195 |
| timepoint.Q | -0.1477110647832 | 0.0788512266278031 | -1.873288103436 | 0.0612516423736164 |
| sexfemale | 0.217916894308364 | 0.0899684063581489 | 2.42214909799418 | 0.0155643094616477 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 8.79376273840496 | 8.93488116469911e-06 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.6650322124337 | 0.234228454080503 | 71.1486240126316 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.246149984528643 | 0.222390203333072 | 1.10683825474086 | 0.268568158837788 |
| sequenceB0map_v4 | 0.248167388730185 | 0.268136140307857 | 0.925527563890696 | 0.354862931125977 |
| timepoint.L | -0.0920800033877545 | 0.138463486377791 | -0.665012891099092 | 0.506159930247094 |
| timepoint.Q | -0.00295739469263832 | 0.076008782176485 | -0.0389085919804837 | 0.968969226641507 |
| sexfemale | -0.0637579506172098 | 0.0712178354552013 | -0.895252575561862 | 0.37081743180053 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 58.8958261240417 | 3.51001013729215e-36 |
| s(NAR_Overall_Accuracy) | 3 | 3 | 1.03693236859079 | 0.375226343587529 |
best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_Overall_Accuracy, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 0.6555408 | 0.5193325 |
| timepoint | 2 | 0.4229695 | 0.6551886 |
| sex | 1 | 0.6996755 | 0.4030462 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 38.902648 | 0.000000 |
| s(age):NAR_Overall_Accuracy | 4 | 4 | 3.860154 | 0.004004 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.6413928229146 | 0.233553880163095 | 71.2529066581708 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.254117160364681 | 0.222076473052776 | 1.14427772051428 | 0.252718799046043 |
| sequenceB0map_v4 | 0.254976251321995 | 0.267268146719235 | 0.95400912698305 | 0.340256103318757 |
| timepoint.L | -0.0934372626660654 | 0.137814099395033 | -0.677994944466711 | 0.497895367006877 |
| timepoint.Q | -0.0014050062851467 | 0.0756790550444156 | -0.0185653254301618 | 0.985190708856292 |
| sexfemale | -0.0593295491251879 | 0.0709288142520089 | -0.836466106910952 | 0.40304622557526 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 38.9026475801087 | 3.4022123369098e-24 |
| s(age):NAR_Overall_Accuracy | 3.99999999999997 | 3.99999999999997 | 3.86015423011053 | 0.00400397327527081 |
[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.006573698 0.07513771 -0.07513771 [2,] 2.542808e-01 -0.022162030 -0.25331316 0.25331316 [3,] -1.567127e-17 0.360564139 -0.03154527 0.03154527 [4,] -1.216003e+00 -6.379376137 -3.60953854 4.60953854
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.698914823609 | 0.233874046010328 | 71.4013166850994 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.209443700129746 | 0.22211875725737 | 0.942935674212613 | 0.345888600676639 |
| sequenceB0map_v4 | 0.191129700940256 | 0.267862065718406 | 0.71353776962649 | 0.475640828972058 |
| timepoint.L | -0.119974602553039 | 0.138733417252052 | -0.864785175262193 | 0.3873158862359 |
| timepoint.Q | -0.0078700671549899 | 0.0760681761397918 | -0.103460705308971 | 0.91761325564783 |
| sexfemale | -0.0770477468752721 | 0.070632811531029 | -1.09082089761392 | 0.275553369734716 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 57.4914869683459 | 2.41786495445284e-35 |
| s(NAR_Overall_Efficiency) | 3 | 3 | 3.41993103113196 | 0.0167525857993048 |
### Comparing interatcion models…
best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_Overall_Efficiency, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 0.3943468 | 0.6742007 |
| timepoint | 2 | 0.5777728 | 0.5612906 |
| sex | 1 | 0.9097077 | 0.3403690 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 35.930157 | 0.0000000 |
| s(age):NAR_Overall_Efficiency | 4 | 4 | 4.484861 | 0.0013318 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.6534398476071 | 0.233481960544904 | 71.32645198259 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.198081605588813 | 0.223044871191485 | 0.888079625102695 | 0.374661949558494 |
| sequenceB0map_v4 | 0.194488238801518 | 0.2682797964525 | 0.724945528411985 | 0.468615709306448 |
| timepoint.L | -0.122962525798049 | 0.138213653393384 | -0.889655419555932 | 0.373815284469178 |
| timepoint.Q | -0.0134895039640845 | 0.075793783951023 | -0.177976388839503 | 0.858769204247666 |
| sexfemale | -0.0673115302884916 | 0.0705729836847655 | -0.953786091702711 | 0.34036896870889 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999999 | 2.99999999999999 | 35.9301589863937 | 2.12353924023525e-22 |
| s(age):NAR_Overall_Efficiency | 4.00000000000002 | 4 | 4.48486076256526 | 0.00133177872368856 |
[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.006573698 0.07513771 -0.07513771 [2,] 2.256165e-01 -0.019663771 -0.22475794 0.22475794 [3,] -1.375621e-17 0.316502485 -0.02769038 0.02769038 [4,] -1.136045e+00 -5.580758844 -3.75967139 4.75967139
best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_F2_Social_Cog_Accuracy, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 0.6913462 | 0.5010851 |
| timepoint | 2 | 0.3424386 | 0.7101006 |
| sex | 1 | 1.0154849 | 0.3137796 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 52.664294 | 0.0000000 |
| s(age):NAR_F2_Social_Cog_Accuracy | 4 | 4 | 1.550996 | 0.1851212 |
best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_F1_Social_Cognition_Efficiency, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 0.2960739 | 0.7437826 |
| timepoint | 2 | 0.5681085 | 0.5667365 |
| sex | 1 | 1.2003598 | 0.2734524 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 44.994999 | 0.000000 |
| s(age):NAR_F1_Social_Cognition_Efficiency | 4 | 4 | 2.875289 | 0.021858 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.6619409417416 | 0.23285398875787 | 71.5553168344787 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.250350753588452 | 0.22084037490989 | 1.13362764254771 | 0.257159141805902 |
| sequenceB0map_v4 | 0.238265769180149 | 0.266476476665691 | 0.894134342218377 | 0.371415011643821 |
| timepoint.L | -0.0871266622549674 | 0.137544652369403 | -0.633442745712658 | 0.526555638426535 |
| timepoint.Q | -0.00323387532386199 | 0.0756168998190862 | -0.0427665684734372 | 0.965894161378631 |
| sexfemale | -0.059894926523171 | 0.0708066008823322 | -0.845894673332866 | 0.397766696064266 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 69.9045527160507 | 6.38485581794442e-42 |
| s(mpraxis_mp2rtcr) | 3 | 3 | 5.37706923857797 | 0.00111361920574243 |
### Comparing interatcion models…
best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = mpraxis_mp2rtcr, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 0.7718817 | 0.4623538 |
| timepoint | 2 | 0.3593921 | 0.6981698 |
| sex | 1 | 0.6194462 | 0.4313963 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 6.712507 | 0.0001705 |
| s(age):mpraxis_mp2rtcr | 4 | 4 | 3.415595 | 0.0086760 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.0153626629912 | 0.30761421809013 | 55.3139668531374 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.273768568852365 | 0.221194186948944 | 1.23768428378978 | 0.216056123998713 |
| sequenceB0map_v4 | 0.284961355900336 | 0.2670356630456 | 1.06712846011012 | 0.28611150562952 |
| timepoint.L | -0.0909451580283361 | 0.138106916374643 | -0.658512697377361 | 0.510325077148447 |
| timepoint.Q | -0.00550823275284094 | 0.075946700469652 | -0.0725276110585213 | 0.942193163858906 |
| sexfemale | -0.0557978118663314 | 0.0708949599815814 | -0.787049063584037 | 0.431396273059775 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 2.99999999999907 | 2.99999999999907 | 6.71250634428106 | 0.000170165599296623 |
| s(age):mpraxis_mp2rtcr | 4.00000000000113 | 4 | 3.41559330239022 | 0.00868116043258085 |
[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.0065736978 0.075137709 -0.075137709 [2,] 1.414214e-03 -0.0001232568 -0.001408832 0.001408832 [3,] -1.585096e-17 0.3646985134 -0.031906986 0.031906986 [4,] -2.675064e+00 -6.2856959425 -2.153100417 3.153100417
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.5938029698312 | 0.236884245553377 | 70.0502599109832 | 0 |
| sequenceB0map_onesizefitsall_v3 | 0.341320452523841 | 0.224764231598261 | 1.51857103817973 | 0.129114589274681 |
| sequenceB0map_v4 | 0.303630078715588 | 0.270110960131226 | 1.12409388559456 | 0.261181521597634 |
| timepoint.L | -0.0496474196770763 | 0.138767384090419 | -0.357774415094015 | 0.720570441291311 |
| timepoint.Q | 0.0042995826573627 | 0.076271926943631 | 0.0563717586490285 | 0.95505435046557 |
| sexfemale | -0.0626682170909903 | 0.0708930008054218 | -0.883983134851269 | 0.376869399099073 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 76.3883270826895 | 1.39642129821805e-46 |
| s(wrat4_std) | 3.00000000000001 | 3 | 2.35722639404123 | 0.0701602110752789 |
best model is Putamen ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = wrat4_std, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 1.3528373 | 0.2588711 |
| timepoint | 2 | 0.1980317 | 0.8203687 |
| sex | 1 | 0.4718535 | 0.4922588 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 1.582250 | 0.1918558 |
| s(age):wrat4_std | 4 | 4 | 3.749673 | 0.0048616 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 16.1545507817039 | 0.326533662774922 | 49.4728495813282 | 1.24173449855074e-300 |
| sequenceB0map_onesizefitsall_v3 | 0.367678173662801 | 0.224185715916317 | 1.64006066202739 | 0.101235603047662 |
| sequenceB0map_v4 | 0.340021956104958 | 0.269622471756245 | 1.26110392019682 | 0.20749872115887 |
| timepoint.L | -0.060998785473273 | 0.138924727711238 | -0.439077955942171 | 0.660678357121173 |
| timepoint.Q | 0.00185147270436671 | 0.0761048670242046 | 0.0243279145836739 | 0.980594798013176 |
| sexfemale | -0.048643641402101 | 0.0708145462973087 | -0.686915950825624 | 0.492258775262108 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000027 | 3 | 1.58224966813178 | 0.191864723337327 |
| s(age):wrat4_std | 4.00000000000071 | 4 | 3.74967243015373 | 0.00486159875133007 |
[,1] [,2] [,3] [,4] [1,] 7.542472e-02 0.006573698 0.07513771 -0.07513771 [2,] 1.571348e-02 -0.001369520 -0.01565369 0.01565369 [3,] -1.611060e-17 0.370672206 -0.03242962 0.03242962 [4,] -2.894424e+00 -6.832049497 -1.88510252 2.88510252
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3202093989911 | 0.489453261602499 | 35.3868505080214 | 8.80329164455521e-193 |
| sequenceB0map_onesizefitsall_v3 | -0.584994368448874 | 0.46600717378543 | -1.25533339690223 | 0.209582834899325 |
| sequenceB0map_v4 | 2.49937686621611 | 0.556881505008487 | 4.48816641195153 | 7.8180326728164e-06 |
| timepoint.L | -0.415022108260038 | 0.282255323920806 | -1.47037831738644 | 0.14170074534393 |
| timepoint.Q | -0.129349074805991 | 0.152886987219103 | -0.846043716072583 | 0.397683698780576 |
| sexfemale | 0.477075709478328 | 0.153006451699252 | 3.11801041184893 | 0.00186063173627339 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 27.4616019845737 | 2.94267273067255e-17 |
| s(NAR_Overall_Accuracy) | 3.00000000000001 | 3 | 0.275916759180048 | 0.842805560764697 |
best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_Overall_Accuracy, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 46.869899 | 0.0000000 |
| timepoint | 2 | 1.062619 | 0.3458491 |
| sex | 1 | 9.629774 | 0.0019557 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 22.6873334 | 0.0000000 |
| s(age):NAR_Overall_Accuracy | 4 | 4 | 0.1609011 | 0.9580581 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3231454429973 | 0.489292395728258 | 35.4044853225518 | 4.43418463259289e-193 |
| sequenceB0map_onesizefitsall_v3 | -0.586019747346675 | 0.465248501374835 | -1.25958438472119 | 0.208044210478284 |
| sequenceB0map_v4 | 2.50598830714678 | 0.556119013698498 | 4.50620864494557 | 7.18967665536314e-06 |
| timepoint.L | -0.411829994648753 | 0.281761962665041 | -1.46162381449031 | 0.144084700296036 |
| timepoint.Q | -0.132372674232584 | 0.15270695908686 | -0.866841138243673 | 0.386188165882453 |
| sexfemale | 0.470975240710563 | 0.152438026248227 | 3.08961780929672 | 0.00204643523154119 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000001 | 3 | 37.9586315818264 | 1.60945424979302e-23 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3333293003351 | 0.489932109406898 | 35.3790432746252 | 1.01362586563262e-192 |
| sequenceB0map_onesizefitsall_v3 | -0.604344401283538 | 0.466692625494864 | -1.29495168397554 | 0.195566300620727 |
| sequenceB0map_v4 | 2.48553331023352 | 0.557469658278193 | 4.45859837091469 | 8.95913840318396e-06 |
| timepoint.L | -0.435925387362487 | 0.283270652010582 | -1.53890063890629 | 0.124071348003807 |
| timepoint.Q | -0.13669200622012 | 0.152985869809449 | -0.893494323301726 | 0.371757503590785 |
| sexfemale | 0.472051627104423 | 0.152524967006234 | 3.09491381227526 | 0.00201063906680067 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 25.5118863281632 | 4.8704473279279e-16 |
| s(NAR_Overall_Efficiency) | 3 | 3 | 0.221398763445024 | 0.881571309253921 |
best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_Overall_Efficiency, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 46.722518 | 0.0000000 |
| timepoint | 2 | 1.024619 | 0.3592225 |
| sex | 1 | 9.527142 | 0.0020673 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 20.0364139 | 0.0000000 |
| s(age):NAR_Overall_Efficiency | 4 | 4 | 0.2723447 | 0.8958936 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3231454429973 | 0.489292395728258 | 35.4044853225518 | 4.43418463259289e-193 |
| sequenceB0map_onesizefitsall_v3 | -0.586019747346675 | 0.465248501374835 | -1.25958438472119 | 0.208044210478284 |
| sequenceB0map_v4 | 2.50598830714678 | 0.556119013698498 | 4.50620864494557 | 7.18967665536314e-06 |
| timepoint.L | -0.411829994648753 | 0.281761962665041 | -1.46162381449031 | 0.144084700296036 |
| timepoint.Q | -0.132372674232584 | 0.15270695908686 | -0.866841138243673 | 0.386188165882453 |
| sexfemale | 0.470975240710563 | 0.152438026248227 | 3.08961780929672 | 0.00204643523154119 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000001 | 3 | 37.9586315818264 | 1.60945424979302e-23 |
best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_F2_Social_Cog_Accuracy, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 46.996460 | 0.0000000 |
| timepoint | 2 | 1.150490 | 0.3168032 |
| sex | 1 | 9.724345 | 0.0018583 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 24.7549022 | 0.0000000 |
| s(age):NAR_F2_Social_Cog_Accuracy | 4 | 4 | 0.2013282 | 0.9376847 |
best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = NAR_F1_Social_Cognition_Efficiency, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 46.790208 | 0.0000000 |
| timepoint | 2 | 1.173055 | 0.3097471 |
| sex | 1 | 9.091559 | 0.0026176 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 25.0965293 | 0.0000000 |
| s(age):NAR_F1_Social_Cognition_Efficiency | 4 | 4 | 0.8921243 | 0.4678602 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3180085901269 | 0.489268619937203 | 35.3957067435669 | 6.84338137207504e-193 |
| sequenceB0map_onesizefitsall_v3 | -0.587564764785295 | 0.465291762155578 | -1.26278780880035 | 0.206891208593279 |
| sequenceB0map_v4 | 2.52078156786512 | 0.556461893542805 | 4.53001651526603 | 6.43766301548061e-06 |
| timepoint.L | -0.42098964034866 | 0.281850007030076 | -1.49366553077196 | 0.135504979382471 |
| timepoint.Q | -0.138344863892345 | 0.152859650543617 | -0.905045009591132 | 0.365608723646604 |
| sexfemale | 0.473119277055444 | 0.152927317071723 | 3.09375254934703 | 0.00201843438749748 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 34.6725348181068 | 1.46793428702995e-21 |
| s(mpraxis_mp2rtcr) | 3 | 3 | 0.186766934134985 | 0.905436038197559 |
best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = mpraxis_mp2rtcr, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 46.1104300 | 0.0000000 |
| timepoint | 2 | 0.9593227 | 0.3834228 |
| sex | 1 | 9.9026310 | 0.0016878 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 0.0360899 | 0.9908223 |
| s(age):mpraxis_mp2rtcr | 4 | 4 | 1.2645015 | 0.2819866 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3231454429973 | 0.489292395728258 | 35.4044853225518 | 4.43418463259289e-193 |
| sequenceB0map_onesizefitsall_v3 | -0.586019747346675 | 0.465248501374835 | -1.25958438472119 | 0.208044210478284 |
| sequenceB0map_v4 | 2.50598830714678 | 0.556119013698498 | 4.50620864494557 | 7.18967665536314e-06 |
| timepoint.L | -0.411829994648753 | 0.281761962665041 | -1.46162381449031 | 0.144084700296036 |
| timepoint.Q | -0.132372674232584 | 0.15270695908686 | -0.866841138243673 | 0.386188165882453 |
| sexfemale | 0.470975240710563 | 0.152438026248227 | 3.08961780929672 | 0.00204643523154119 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000001 | 3 | 37.9586315818264 | 1.60945424979302e-23 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3578564242176 | 0.497115928968418 | 34.917119755622 | 8.664254455773e-189 |
| sequenceB0map_onesizefitsall_v3 | -0.621268640274621 | 0.473091774054821 | -1.31320955963743 | 0.189344977030271 |
| sequenceB0map_v4 | 2.46069075079442 | 0.563014463153034 | 4.37056401182641 | 1.33837460909102e-05 |
| timepoint.L | -0.408987927814109 | 0.283440536744067 | -1.4429408457669 | 0.14927896513991 |
| timepoint.Q | -0.133445632792116 | 0.153414375832877 | -0.869837862766429 | 0.384550212144775 |
| sexfemale | 0.477518794863343 | 0.153489573696144 | 3.11108294436119 | 0.001904758089292 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3 | 3 | 37.0212924391122 | 5.920627011736e-23 |
| s(wrat4_std) | 3.00000000000001 | 3 | 0.0606958859794548 | 0.980418876514485 |
best model is Accumbens_Area ~ sequence + timepoint + sex + s(age, k = 4, fx = T) +
best model is s(age, by = wrat4_std, k = 4, fx = T)| df | F | p-value | |
|---|---|---|---|
| sequence | 2 | 45.2148025 | 0.0000000 |
| timepoint | 2 | 0.8645941 | 0.4214657 |
| sex | 1 | 9.1695450 | 0.0025095 |
| edf | Ref.df | F | p-value | |
|---|---|---|---|---|
| s(age) | 3 | 3 | 3.136645 | 0.0246412 |
| s(age):wrat4_std | 4 | 4 | 0.924000 | 0.4490601 |
Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
The simpler model is best Maximum number of PQL iterations: 20
## iteration 1
## iteration 2
| term | estimate | std.error | statistic | p.value |
|---|---|---|---|---|
| (Intercept) | 17.3231454429973 | 0.489292395728258 | 35.4044853225518 | 4.43418463259289e-193 |
| sequenceB0map_onesizefitsall_v3 | -0.586019747346675 | 0.465248501374835 | -1.25958438472119 | 0.208044210478284 |
| sequenceB0map_v4 | 2.50598830714678 | 0.556119013698498 | 4.50620864494557 | 7.18967665536314e-06 |
| timepoint.L | -0.411829994648753 | 0.281761962665041 | -1.46162381449031 | 0.144084700296036 |
| timepoint.Q | -0.132372674232584 | 0.15270695908686 | -0.866841138243673 | 0.386188165882453 |
| sexfemale | 0.470975240710563 | 0.152438026248227 | 3.08961780929672 | 0.00204643523154119 |
| term | edf | ref.df | statistic | p.value |
| s(age) | 3.00000000000001 | 3 | 37.9586315818264 | 1.60945424979302e-23 |
Run the models:
cog_vars <- c("wrat4_std","wrat4_raw") #"wrat3_raw",
for (cv in cog_vars) {
cat(sprintf("/n/n### Results for %s",cv))
model_formula <- sprintf("R2s ~ sex + ti(age, k=4, fx = T) + ti(%s, k=4, fx = T) + ti(age,%s, k=4, fx = T)",cv,cv)
thisTable <- longTable
if (str_detect(cv,"wrat4")) {
thisTable$exclusions <- thisTable$scan2cnbmonths>6 | thisTable$age>=40 #There is one old person
} else {
thisTable$exclusions <- thisTable$scan2cnbmonths>6
}
models <- thisTable %>%
group_by(ROI)%>%
nest()%>%
mutate(results=purrr::pmap(list(data,model_formula,
this_label = ROI,
smooth_var = "age",
int_var = cv,
group_var = "bblid",
pbootstrap = T),
.f=gamm_model))
}